/**   
 * @Title: ConListAdapter.java 
 * @Package com.cdtv.home.adapter 
 * @Description: 
 * @author zhuw
 * @date 2012-7-18 下午3:27:20 
 */
package com.adpter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.ocean.util.common.StringUtil;
import com.common.method.ServerPath;
import com.matang.R;
import com.modle.JobStruct;
import com.util.OUtil;

/**
 * 
 * @ClassName:ZpInfoListAdapter
 * @Description:TODO
 * @author zhuw
 * @date 2013-7-24 下午2:30:06
 */
public class JobInfoListAdapter extends CusBaseAdapter {
	private List<JobStruct> list;
	private Context context;

	/**
	 * @param list
	 * @param context
	 */
	public JobInfoListAdapter(List<JobStruct> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder vh = null;
		if (view == null) {
			view = LayoutInflater.from(context).inflate(
					R.layout.list_item_zpinfo, null);
			vh = new ViewHolder();
			vh.nameTv = (TextView) view.findViewById(R.id.name_tv);
			vh.descTv = (TextView) view.findViewById(R.id.demand_tv);
			vh.timeTv = (TextView) view.findViewById(R.id.time_tv);
			vh.placeTv = (TextView) view.findViewById(R.id.place_tv);
			vh.thumbIv = (ImageView) view.findViewById(R.id.thumb_iv);
			vh. bgIv = (ImageView) view.findViewById(R.id.bg_iv);

			view.setTag(vh);
		} else {
			vh = (ViewHolder) view.getTag();

		}
		imageLoader.bind(vh.thumbIv,ServerPath.SERVER+list.get(position).thumb, null,R.drawable.default_head);

		vh.nameTv.setText(list.get(position).name);
		vh.timeTv
				.setText(StringUtil.getTimeStr2(list.get(position).updateTimeStr));
		vh.descTv.setText(list.get(position).desc);
		vh.placeTv.setText(list.get(position).place);
		
		
		OUtil.setThumbBg(list.get(position).uType,list.get(position).uIsMember, vh.bgIv);

		return view;
	}

	class ViewHolder {
		TextView nameTv, timeTv, descTv, placeTv;
		ImageView thumbIv;
		ImageView bgIv;

	}

}
